package com.xuln.mybatis.dao;

import org.apache.ibatis.session.SqlSession;

import com.xuln.mybatis.model.User;
import com.xuln.mybatis.model.UserMapper;


public class UserDao {
	public User getUser(int id) {
		SqlSession session = SessionFactioryUtil.getSessionFactory().openSession();
		try {
			return (User) session.selectOne("org.mybatis.example.UserMapper.getUser", id);
		} finally {
			session.close();
		}
	}

	public User getUserByMapper(int id) {
		SqlSession session = SessionFactioryUtil.getSessionFactory().openSession();
		try {
			UserMapper mapper = session.getMapper(UserMapper.class);
			return mapper.getUser(id);
		} finally {
			session.close();
		}
	}

}
